1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.HashTable;
26 
27 private import glib.ConstructionException;
28 private import glib.ListG;
29 private import glib.c.functions;
30 public  import glib.c.types;
31 
32 
33 /**
34  * The #GHashTable struct is an opaque data structure to represent a
35  * [Hash Table][glib-Hash-Tables]. It should only be accessed via the
36  * following functions.
37  */
38 public class HashTable
39 {
40 	/** the main Gtk struct */
41 	protected GHashTable* gHashTable;
42 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public GHashTable* getHashTableStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gHashTable;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)gHashTable;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GHashTable* gHashTable, bool ownedRef = false)
62 	{
63 		this.gHashTable = gHashTable;
64 		this.ownedRef = ownedRef;
65 	}
66 
67 
68 	/**
69 	 * This is a convenience function for using a #GHashTable as a set.  It
70 	 * is equivalent to calling g_hash_table_replace() with @key as both the
71 	 * key and the value.
72 	 *
73 	 * In particular, this means that if @key already exists in the hash table, then
74 	 * the old copy of @key in the hash table is freed and @key replaces it in the
75 	 * table.
76 	 *
77 	 * When a hash table only ever contains keys that have themselves as the
78 	 * corresponding value it is able to be stored more efficiently.  See
79 	 * the discussion in the section description.
80 	 *
81 	 * Starting from GLib 2.40, this function returns a boolean value to
82 	 * indicate whether the newly added value was already in the hash table
83 	 * or not.
84 	 *
85 	 * Params:
86 	 *     key = a key to insert
87 	 *
88 	 * Returns: %TRUE if the key did not exist yet
89 	 *
90 	 * Since: 2.32
91 	 */
92 	public bool add(void* key)
93 	{
94 		return g_hash_table_add(gHashTable, key) != 0;
95 	}
96 
97 	/**
98 	 * Checks if @key is in @hash_table.
99 	 *
100 	 * Params:
101 	 *     key = a key to check
102 	 *
103 	 * Returns: %TRUE if @key is in @hash_table, %FALSE otherwise.
104 	 *
105 	 * Since: 2.32
106 	 */
107 	public bool contains(void* key)
108 	{
109 		return g_hash_table_contains(gHashTable, key) != 0;
110 	}
111 
112 	/**
113 	 * Destroys all keys and values in the #GHashTable and decrements its
114 	 * reference count by 1. If keys and/or values are dynamically allocated,
115 	 * you should either free them first or create the #GHashTable with destroy
116 	 * notifiers using g_hash_table_new_full(). In the latter case the destroy
117 	 * functions you supplied will be called on all keys and values during the
118 	 * destruction phase.
119 	 */
120 	public void destroy()
121 	{
122 		g_hash_table_destroy(gHashTable);
123 	}
124 
125 	/**
126 	 * Calls the given function for key/value pairs in the #GHashTable
127 	 * until @predicate returns %TRUE. The function is passed the key
128 	 * and value of each pair, and the given @user_data parameter. The
129 	 * hash table may not be modified while iterating over it (you can't
130 	 * add/remove items).
131 	 *
132 	 * Note, that hash tables are really only optimized for forward
133 	 * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
134 	 * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
135 	 * once per every entry in a hash table) should probably be reworked
136 	 * to use additional or different data structures for reverse lookups
137 	 * (keep in mind that an O(n) find/foreach operation issued for all n
138 	 * values in a hash table ends up needing O(n*n) operations).
139 	 *
140 	 * Params:
141 	 *     predicate = function to test the key/value pairs for a certain property
142 	 *     userData = user data to pass to the function
143 	 *
144 	 * Returns: The value of the first key/value pair is returned,
145 	 *     for which @predicate evaluates to %TRUE. If no pair with the
146 	 *     requested property is found, %NULL is returned.
147 	 *
148 	 * Since: 2.4
149 	 */
150 	public void* find(GHRFunc predicate, void* userData)
151 	{
152 		return g_hash_table_find(gHashTable, predicate, userData);
153 	}
154 
155 	alias foreac = foreach_;
156 	/**
157 	 * Calls the given function for each of the key/value pairs in the
158 	 * #GHashTable.  The function is passed the key and value of each
159 	 * pair, and the given @user_data parameter.  The hash table may not
160 	 * be modified while iterating over it (you can't add/remove
161 	 * items). To remove all items matching a predicate, use
162 	 * g_hash_table_foreach_remove().
163 	 *
164 	 * The order in which g_hash_table_foreach() iterates over the keys/values in
165 	 * the hash table is not defined.
166 	 *
167 	 * See g_hash_table_find() for performance caveats for linear
168 	 * order searches in contrast to g_hash_table_lookup().
169 	 *
170 	 * Params:
171 	 *     func = the function to call for each key/value pair
172 	 *     userData = user data to pass to the function
173 	 */
174 	public void foreach_(GHFunc func, void* userData)
175 	{
176 		g_hash_table_foreach(gHashTable, func, userData);
177 	}
178 
179 	/**
180 	 * Calls the given function for each key/value pair in the
181 	 * #GHashTable. If the function returns %TRUE, then the key/value
182 	 * pair is removed from the #GHashTable. If you supplied key or
183 	 * value destroy functions when creating the #GHashTable, they are
184 	 * used to free the memory allocated for the removed keys and values.
185 	 *
186 	 * See #GHashTableIter for an alternative way to loop over the
187 	 * key/value pairs in the hash table.
188 	 *
189 	 * Params:
190 	 *     func = the function to call for each key/value pair
191 	 *     userData = user data to pass to the function
192 	 *
193 	 * Returns: the number of key/value pairs removed
194 	 */
195 	public uint foreachRemove(GHRFunc func, void* userData)
196 	{
197 		return g_hash_table_foreach_remove(gHashTable, func, userData);
198 	}
199 
200 	/**
201 	 * Calls the given function for each key/value pair in the
202 	 * #GHashTable. If the function returns %TRUE, then the key/value
203 	 * pair is removed from the #GHashTable, but no key or value
204 	 * destroy functions are called.
205 	 *
206 	 * See #GHashTableIter for an alternative way to loop over the
207 	 * key/value pairs in the hash table.
208 	 *
209 	 * Params:
210 	 *     func = the function to call for each key/value pair
211 	 *     userData = user data to pass to the function
212 	 *
213 	 * Returns: the number of key/value pairs removed.
214 	 */
215 	public uint foreachSteal(GHRFunc func, void* userData)
216 	{
217 		return g_hash_table_foreach_steal(gHashTable, func, userData);
218 	}
219 
220 	/**
221 	 * Retrieves every key inside @hash_table. The returned data is valid
222 	 * until changes to the hash release those keys.
223 	 *
224 	 * This iterates over every entry in the hash table to build its return value.
225 	 * To iterate over the entries in a #GHashTable more efficiently, use a
226 	 * #GHashTableIter.
227 	 *
228 	 * Returns: a #GList containing all the keys
229 	 *     inside the hash table. The content of the list is owned by the
230 	 *     hash table and should not be modified or freed. Use g_list_free()
231 	 *     when done using the list.
232 	 *
233 	 * Since: 2.14
234 	 */
235 	public ListG getKeys()
236 	{
237 		auto __p = g_hash_table_get_keys(gHashTable);
238 
239 		if(__p is null)
240 		{
241 			return null;
242 		}
243 
244 		return new ListG(cast(GList*) __p);
245 	}
246 
247 	/**
248 	 * Retrieves every key inside @hash_table, as an array.
249 	 *
250 	 * The returned array is %NULL-terminated but may contain %NULL as a
251 	 * key.  Use @length to determine the true length if it's possible that
252 	 * %NULL was used as the value for a key.
253 	 *
254 	 * Note: in the common case of a string-keyed #GHashTable, the return
255 	 * value of this function can be conveniently cast to (const gchar **).
256 	 *
257 	 * This iterates over every entry in the hash table to build its return value.
258 	 * To iterate over the entries in a #GHashTable more efficiently, use a
259 	 * #GHashTableIter.
260 	 *
261 	 * You should always free the return result with g_free().  In the
262 	 * above-mentioned case of a string-keyed hash table, it may be
263 	 * appropriate to use g_strfreev() if you call g_hash_table_steal_all()
264 	 * first to transfer ownership of the keys.
265 	 *
266 	 * Returns: a
267 	 *     %NULL-terminated array containing each key from the table.
268 	 *
269 	 * Since: 2.40
270 	 */
271 	public void*[] getKeysAsArray()
272 	{
273 		uint length;
274 
275 		auto __p = g_hash_table_get_keys_as_array(gHashTable, &length);
276 
277 		return __p[0 .. length];
278 	}
279 
280 	/**
281 	 * Retrieves every value inside @hash_table. The returned data
282 	 * is valid until @hash_table is modified.
283 	 *
284 	 * This iterates over every entry in the hash table to build its return value.
285 	 * To iterate over the entries in a #GHashTable more efficiently, use a
286 	 * #GHashTableIter.
287 	 *
288 	 * Returns: a #GList containing all the values
289 	 *     inside the hash table. The content of the list is owned by the
290 	 *     hash table and should not be modified or freed. Use g_list_free()
291 	 *     when done using the list.
292 	 *
293 	 * Since: 2.14
294 	 */
295 	public ListG getValues()
296 	{
297 		auto __p = g_hash_table_get_values(gHashTable);
298 
299 		if(__p is null)
300 		{
301 			return null;
302 		}
303 
304 		return new ListG(cast(GList*) __p);
305 	}
306 
307 	/**
308 	 * Inserts a new key and value into a #GHashTable.
309 	 *
310 	 * If the key already exists in the #GHashTable its current
311 	 * value is replaced with the new value. If you supplied a
312 	 * @value_destroy_func when creating the #GHashTable, the old
313 	 * value is freed using that function. If you supplied a
314 	 * @key_destroy_func when creating the #GHashTable, the passed
315 	 * key is freed using that function.
316 	 *
317 	 * Starting from GLib 2.40, this function returns a boolean value to
318 	 * indicate whether the newly added value was already in the hash table
319 	 * or not.
320 	 *
321 	 * Params:
322 	 *     key = a key to insert
323 	 *     value = the value to associate with the key
324 	 *
325 	 * Returns: %TRUE if the key did not exist yet
326 	 */
327 	public bool insert(void* key, void* value)
328 	{
329 		return g_hash_table_insert(gHashTable, key, value) != 0;
330 	}
331 
332 	/**
333 	 * Looks up a key in a #GHashTable. Note that this function cannot
334 	 * distinguish between a key that is not present and one which is present
335 	 * and has the value %NULL. If you need this distinction, use
336 	 * g_hash_table_lookup_extended().
337 	 *
338 	 * Params:
339 	 *     key = the key to look up
340 	 *
341 	 * Returns: the associated value, or %NULL if the key is not found
342 	 */
343 	public void* lookup(void* key)
344 	{
345 		return g_hash_table_lookup(gHashTable, key);
346 	}
347 
348 	/**
349 	 * Looks up a key in the #GHashTable, returning the original key and the
350 	 * associated value and a #gboolean which is %TRUE if the key was found. This
351 	 * is useful if you need to free the memory allocated for the original key,
352 	 * for example before calling g_hash_table_remove().
353 	 *
354 	 * You can actually pass %NULL for @lookup_key to test
355 	 * whether the %NULL key exists, provided the hash and equal functions
356 	 * of @hash_table are %NULL-safe.
357 	 *
358 	 * Params:
359 	 *     lookupKey = the key to look up
360 	 *     origKey = return location for the original key
361 	 *     value = return location for the value associated
362 	 *         with the key
363 	 *
364 	 * Returns: %TRUE if the key was found in the #GHashTable
365 	 */
366 	public bool lookupExtended(void* lookupKey, out void* origKey, out void* value)
367 	{
368 		return g_hash_table_lookup_extended(gHashTable, lookupKey, &origKey, &value) != 0;
369 	}
370 
371 	/**
372 	 * Creates a new #GHashTable with a reference count of 1.
373 	 *
374 	 * Hash values returned by @hash_func are used to determine where keys
375 	 * are stored within the #GHashTable data structure. The g_direct_hash(),
376 	 * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
377 	 * functions are provided for some common types of keys.
378 	 * If @hash_func is %NULL, g_direct_hash() is used.
379 	 *
380 	 * @key_equal_func is used when looking up keys in the #GHashTable.
381 	 * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
382 	 * and g_str_equal() functions are provided for the most common types
383 	 * of keys. If @key_equal_func is %NULL, keys are compared directly in
384 	 * a similar fashion to g_direct_equal(), but without the overhead of
385 	 * a function call. @key_equal_func is called with the key from the hash table
386 	 * as its first parameter, and the user-provided key to check against as
387 	 * its second.
388 	 *
389 	 * Params:
390 	 *     hashFunc = a function to create a hash value from a key
391 	 *     keyEqualFunc = a function to check two keys for equality
392 	 *
393 	 * Returns: a new #GHashTable
394 	 *
395 	 * Throws: ConstructionException GTK+ fails to create the object.
396 	 */
397 	public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc)
398 	{
399 		auto __p = g_hash_table_new(hashFunc, keyEqualFunc);
400 
401 		if(__p is null)
402 		{
403 			throw new ConstructionException("null returned by new");
404 		}
405 
406 		this(cast(GHashTable*) __p);
407 	}
408 
409 	/**
410 	 * Creates a new #GHashTable like g_hash_table_new() with a reference
411 	 * count of 1 and allows to specify functions to free the memory
412 	 * allocated for the key and value that get called when removing the
413 	 * entry from the #GHashTable.
414 	 *
415 	 * Since version 2.42 it is permissible for destroy notify functions to
416 	 * recursively remove further items from the hash table. This is only
417 	 * permissible if the application still holds a reference to the hash table.
418 	 * This means that you may need to ensure that the hash table is empty by
419 	 * calling g_hash_table_remove_all() before releasing the last reference using
420 	 * g_hash_table_unref().
421 	 *
422 	 * Params:
423 	 *     hashFunc = a function to create a hash value from a key
424 	 *     keyEqualFunc = a function to check two keys for equality
425 	 *     keyDestroyFunc = a function to free the memory allocated for the key
426 	 *         used when removing the entry from the #GHashTable, or %NULL
427 	 *         if you don't want to supply such a function.
428 	 *     valueDestroyFunc = a function to free the memory allocated for the
429 	 *         value used when removing the entry from the #GHashTable, or %NULL
430 	 *         if you don't want to supply such a function.
431 	 *
432 	 * Returns: a new #GHashTable
433 	 *
434 	 * Throws: ConstructionException GTK+ fails to create the object.
435 	 */
436 	public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc, GDestroyNotify keyDestroyFunc, GDestroyNotify valueDestroyFunc)
437 	{
438 		auto __p = g_hash_table_new_full(hashFunc, keyEqualFunc, keyDestroyFunc, valueDestroyFunc);
439 
440 		if(__p is null)
441 		{
442 			throw new ConstructionException("null returned by new_full");
443 		}
444 
445 		this(cast(GHashTable*) __p);
446 	}
447 
448 	/**
449 	 * Creates a new #GHashTable like g_hash_table_new_full() with a reference
450 	 * count of 1.
451 	 *
452 	 * It inherits the hash function, the key equal function, the key destroy function,
453 	 * as well as the value destroy function, from @other_hash_table.
454 	 *
455 	 * The returned hash table will be empty; it will not contain the keys
456 	 * or values from @other_hash_table.
457 	 *
458 	 * Returns: a new #GHashTable
459 	 *
460 	 * Since: 2.72
461 	 *
462 	 * Throws: ConstructionException GTK+ fails to create the object.
463 	 */
464 	public this(HashTable otherHashTable)
465 	{
466 		auto __p = g_hash_table_new_similar((otherHashTable is null) ? null : otherHashTable.getHashTableStruct());
467 
468 		if(__p is null)
469 		{
470 			throw new ConstructionException("null returned by new_similar");
471 		}
472 
473 		this(cast(GHashTable*) __p);
474 	}
475 
476 	alias doref = ref_;
477 	/**
478 	 * Atomically increments the reference count of @hash_table by one.
479 	 * This function is MT-safe and may be called from any thread.
480 	 *
481 	 * Returns: the passed in #GHashTable
482 	 *
483 	 * Since: 2.10
484 	 */
485 	public HashTable ref_()
486 	{
487 		auto __p = g_hash_table_ref(gHashTable);
488 
489 		if(__p is null)
490 		{
491 			return null;
492 		}
493 
494 		return new HashTable(cast(GHashTable*) __p);
495 	}
496 
497 	/**
498 	 * Removes a key and its associated value from a #GHashTable.
499 	 *
500 	 * If the #GHashTable was created using g_hash_table_new_full(), the
501 	 * key and value are freed using the supplied destroy functions, otherwise
502 	 * you have to make sure that any dynamically allocated values are freed
503 	 * yourself.
504 	 *
505 	 * Params:
506 	 *     key = the key to remove
507 	 *
508 	 * Returns: %TRUE if the key was found and removed from the #GHashTable
509 	 */
510 	public bool remove(void* key)
511 	{
512 		return g_hash_table_remove(gHashTable, key) != 0;
513 	}
514 
515 	/**
516 	 * Removes all keys and their associated values from a #GHashTable.
517 	 *
518 	 * If the #GHashTable was created using g_hash_table_new_full(),
519 	 * the keys and values are freed using the supplied destroy functions,
520 	 * otherwise you have to make sure that any dynamically allocated
521 	 * values are freed yourself.
522 	 *
523 	 * Since: 2.12
524 	 */
525 	public void removeAll()
526 	{
527 		g_hash_table_remove_all(gHashTable);
528 	}
529 
530 	/**
531 	 * Inserts a new key and value into a #GHashTable similar to
532 	 * g_hash_table_insert(). The difference is that if the key
533 	 * already exists in the #GHashTable, it gets replaced by the
534 	 * new key. If you supplied a @value_destroy_func when creating
535 	 * the #GHashTable, the old value is freed using that function.
536 	 * If you supplied a @key_destroy_func when creating the
537 	 * #GHashTable, the old key is freed using that function.
538 	 *
539 	 * Starting from GLib 2.40, this function returns a boolean value to
540 	 * indicate whether the newly added value was already in the hash table
541 	 * or not.
542 	 *
543 	 * Params:
544 	 *     key = a key to insert
545 	 *     value = the value to associate with the key
546 	 *
547 	 * Returns: %TRUE if the key did not exist yet
548 	 */
549 	public bool replace(void* key, void* value)
550 	{
551 		return g_hash_table_replace(gHashTable, key, value) != 0;
552 	}
553 
554 	/**
555 	 * Returns the number of elements contained in the #GHashTable.
556 	 *
557 	 * Returns: the number of key/value pairs in the #GHashTable.
558 	 */
559 	public uint size()
560 	{
561 		return g_hash_table_size(gHashTable);
562 	}
563 
564 	/**
565 	 * Removes a key and its associated value from a #GHashTable without
566 	 * calling the key and value destroy functions.
567 	 *
568 	 * Params:
569 	 *     key = the key to remove
570 	 *
571 	 * Returns: %TRUE if the key was found and removed from the #GHashTable
572 	 */
573 	public bool steal(void* key)
574 	{
575 		return g_hash_table_steal(gHashTable, key) != 0;
576 	}
577 
578 	/**
579 	 * Removes all keys and their associated values from a #GHashTable
580 	 * without calling the key and value destroy functions.
581 	 *
582 	 * Since: 2.12
583 	 */
584 	public void stealAll()
585 	{
586 		g_hash_table_steal_all(gHashTable);
587 	}
588 
589 	/**
590 	 * Looks up a key in the #GHashTable, stealing the original key and the
591 	 * associated value and returning %TRUE if the key was found. If the key was
592 	 * not found, %FALSE is returned.
593 	 *
594 	 * If found, the stolen key and value are removed from the hash table without
595 	 * calling the key and value destroy functions, and ownership is transferred to
596 	 * the caller of this method; as with g_hash_table_steal().
597 	 *
598 	 * You can pass %NULL for @lookup_key, provided the hash and equal functions
599 	 * of @hash_table are %NULL-safe.
600 	 *
601 	 * Params:
602 	 *     lookupKey = the key to look up
603 	 *     stolenKey = return location for the
604 	 *         original key
605 	 *     stolenValue = return location
606 	 *         for the value associated with the key
607 	 *
608 	 * Returns: %TRUE if the key was found in the #GHashTable
609 	 *
610 	 * Since: 2.58
611 	 */
612 	public bool stealExtended(void* lookupKey, out void* stolenKey, out void* stolenValue)
613 	{
614 		return g_hash_table_steal_extended(gHashTable, lookupKey, &stolenKey, &stolenValue) != 0;
615 	}
616 
617 	/**
618 	 * Atomically decrements the reference count of @hash_table by one.
619 	 * If the reference count drops to 0, all keys and values will be
620 	 * destroyed, and all memory allocated by the hash table is released.
621 	 * This function is MT-safe and may be called from any thread.
622 	 *
623 	 * Since: 2.10
624 	 */
625 	public void unref()
626 	{
627 		g_hash_table_unref(gHashTable);
628 	}
629 
630 	/**
631 	 * Compares two #gpointer arguments and returns %TRUE if they are equal.
632 	 * It can be passed to g_hash_table_new() as the @key_equal_func
633 	 * parameter, when using opaque pointers compared by pointer value as
634 	 * keys in a #GHashTable.
635 	 *
636 	 * This equality function is also appropriate for keys that are integers
637 	 * stored in pointers, such as `GINT_TO_POINTER (n)`.
638 	 *
639 	 * Params:
640 	 *     v1 = a key
641 	 *     v2 = a key to compare with @v1
642 	 *
643 	 * Returns: %TRUE if the two keys match.
644 	 */
645 	public static bool directEqual(void* v1, void* v2)
646 	{
647 		return g_direct_equal(v1, v2) != 0;
648 	}
649 
650 	/**
651 	 * Converts a gpointer to a hash value.
652 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
653 	 * when using opaque pointers compared by pointer value as keys in a
654 	 * #GHashTable.
655 	 *
656 	 * This hash function is also appropriate for keys that are integers
657 	 * stored in pointers, such as `GINT_TO_POINTER (n)`.
658 	 *
659 	 * Params:
660 	 *     v = a #gpointer key
661 	 *
662 	 * Returns: a hash value corresponding to the key.
663 	 */
664 	public static uint directHash(void* v)
665 	{
666 		return g_direct_hash(v);
667 	}
668 
669 	/**
670 	 * Compares the two #gdouble values being pointed to and returns
671 	 * %TRUE if they are equal.
672 	 * It can be passed to g_hash_table_new() as the @key_equal_func
673 	 * parameter, when using non-%NULL pointers to doubles as keys in a
674 	 * #GHashTable.
675 	 *
676 	 * Params:
677 	 *     v1 = a pointer to a #gdouble key
678 	 *     v2 = a pointer to a #gdouble key to compare with @v1
679 	 *
680 	 * Returns: %TRUE if the two keys match.
681 	 *
682 	 * Since: 2.22
683 	 */
684 	public static bool doubleEqual(void* v1, void* v2)
685 	{
686 		return g_double_equal(v1, v2) != 0;
687 	}
688 
689 	/**
690 	 * Converts a pointer to a #gdouble to a hash value.
691 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
692 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
693 	 * when using non-%NULL pointers to doubles as keys in a #GHashTable.
694 	 *
695 	 * Params:
696 	 *     v = a pointer to a #gdouble key
697 	 *
698 	 * Returns: a hash value corresponding to the key.
699 	 *
700 	 * Since: 2.22
701 	 */
702 	public static uint doubleHash(void* v)
703 	{
704 		return g_double_hash(v);
705 	}
706 
707 	/**
708 	 * Compares the two #gint64 values being pointed to and returns
709 	 * %TRUE if they are equal.
710 	 * It can be passed to g_hash_table_new() as the @key_equal_func
711 	 * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
712 	 * #GHashTable.
713 	 *
714 	 * Params:
715 	 *     v1 = a pointer to a #gint64 key
716 	 *     v2 = a pointer to a #gint64 key to compare with @v1
717 	 *
718 	 * Returns: %TRUE if the two keys match.
719 	 *
720 	 * Since: 2.22
721 	 */
722 	public static bool int64Equal(void* v1, void* v2)
723 	{
724 		return g_int64_equal(v1, v2) != 0;
725 	}
726 
727 	/**
728 	 * Converts a pointer to a #gint64 to a hash value.
729 	 *
730 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
731 	 * when using non-%NULL pointers to 64-bit integer values as keys in a
732 	 * #GHashTable.
733 	 *
734 	 * Params:
735 	 *     v = a pointer to a #gint64 key
736 	 *
737 	 * Returns: a hash value corresponding to the key.
738 	 *
739 	 * Since: 2.22
740 	 */
741 	public static uint int64Hash(void* v)
742 	{
743 		return g_int64_hash(v);
744 	}
745 
746 	/**
747 	 * Compares the two #gint values being pointed to and returns
748 	 * %TRUE if they are equal.
749 	 * It can be passed to g_hash_table_new() as the @key_equal_func
750 	 * parameter, when using non-%NULL pointers to integers as keys in a
751 	 * #GHashTable.
752 	 *
753 	 * Note that this function acts on pointers to #gint, not on #gint
754 	 * directly: if your hash table's keys are of the form
755 	 * `GINT_TO_POINTER (n)`, use g_direct_equal() instead.
756 	 *
757 	 * Params:
758 	 *     v1 = a pointer to a #gint key
759 	 *     v2 = a pointer to a #gint key to compare with @v1
760 	 *
761 	 * Returns: %TRUE if the two keys match.
762 	 */
763 	public static bool intEqual(void* v1, void* v2)
764 	{
765 		return g_int_equal(v1, v2) != 0;
766 	}
767 
768 	/**
769 	 * Converts a pointer to a #gint to a hash value.
770 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
771 	 * when using non-%NULL pointers to integer values as keys in a #GHashTable.
772 	 *
773 	 * Note that this function acts on pointers to #gint, not on #gint
774 	 * directly: if your hash table's keys are of the form
775 	 * `GINT_TO_POINTER (n)`, use g_direct_hash() instead.
776 	 *
777 	 * Params:
778 	 *     v = a pointer to a #gint key
779 	 *
780 	 * Returns: a hash value corresponding to the key.
781 	 */
782 	public static uint intHash(void* v)
783 	{
784 		return g_int_hash(v);
785 	}
786 
787 	/**
788 	 * Compares two strings for byte-by-byte equality and returns %TRUE
789 	 * if they are equal. It can be passed to g_hash_table_new() as the
790 	 * @key_equal_func parameter, when using non-%NULL strings as keys in a
791 	 * #GHashTable.
792 	 *
793 	 * This function is typically used for hash table comparisons, but can be used
794 	 * for general purpose comparisons of non-%NULL strings. For a %NULL-safe string
795 	 * comparison function, see g_strcmp0().
796 	 *
797 	 * Params:
798 	 *     v1 = a key
799 	 *     v2 = a key to compare with @v1
800 	 *
801 	 * Returns: %TRUE if the two keys match
802 	 */
803 	public static bool strEqual(void* v1, void* v2)
804 	{
805 		return g_str_equal(v1, v2) != 0;
806 	}
807 
808 	/**
809 	 * Converts a string to a hash value.
810 	 *
811 	 * This function implements the widely used "djb" hash apparently
812 	 * posted by Daniel Bernstein to comp.lang.c some time ago.  The 32
813 	 * bit unsigned hash value starts at 5381 and for each byte 'c' in
814 	 * the string, is updated: `hash = hash * 33 + c`. This function
815 	 * uses the signed value of each byte.
816 	 *
817 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
818 	 * when using non-%NULL strings as keys in a #GHashTable.
819 	 *
820 	 * Note that this function may not be a perfect fit for all use cases.
821 	 * For example, it produces some hash collisions with strings as short
822 	 * as 2.
823 	 *
824 	 * Params:
825 	 *     v = a string key
826 	 *
827 	 * Returns: a hash value corresponding to the key
828 	 */
829 	public static uint strHash(void* v)
830 	{
831 		return g_str_hash(v);
832 	}
833 }